﻿#ifndef WINMEDIADEVICE_H
#define WINMEDIADEVICE_H

#include <QObject>
#include <QSemaphore>


#include <mmdeviceapi.h>

#include "MediaDevice.h"

extern "C"
{
#include "libavformat/avformat.h"
};

struct IAudioClient;

class WinMediaDevice : public MediaDevice
{
    Q_OBJECT
public:
    explicit WinMediaDevice(QObject *parent = nullptr);

    /* 设备名称:UID */
    static QList<QPair<QString,QString>> getDeviceList(MediaDeviceType type);

    virtual bool isSupport(IAudioClient *client,WAVEFORMATEX *pwfx);
    virtual bool isPrepare() override;

protected:
    BOOL AdjustFormatTo16Bits(WAVEFORMATEX *pwfx);
    virtual IMMDevice *getDevice() = 0;

signals:
    void audioData(AVFrame *frame);

protected:
    IMMDevice* pDevice = nullptr;

    QSemaphore m_sem;
};

#endif // WINMEDIADEVICE_H
